/* $RCSFile: DecimalDataType.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/UI/DataTypes/DecimalDataType.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:29  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Globalization;
using System.Diagnostics;
using System.Web.UI;
using System.Web.UI.WebControls;

using AddonNice.Diagnostics;
using AddonNice.UI;
using AddonNice.Configuration;

using Telerik.Web.UI;

namespace AddonNice.UI.DataTypes
{
	/// <summary>
	/// DecimalDataType
	/// </summary>
	public class DecimalDataType : NumericDataType
	{
		public DecimalDataType()
		{
			InnerDataType		= PropertiesDataType.Integer;
		}

		public override string Val
		{
			get
			{
				return innerValue;
			}
			set
			{
				try
				{
					innerValue = decimal.Parse(value,CultureInfo.InvariantCulture).ToString();
				}
				catch (Exception ex)
				{
					if ( GlobalTraceSwitch.Sw.TraceError )
                        Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[E]DecimalDataType Set value: {0}, ex: {1}",value,ex),DataTypeTraceSwitch.Sw.Info);
                    throw;
				}
			}
		}

		public override string Description
		{
			get
			{
				return "Decimal";
			}
		}
	}
}